package com.shopping.dao.Impl;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.springframework.stereotype.Repository;

import com.shopping.model.Items;

@Repository
public interface IItemsDao {

	@Select("select * from items where order_id = #{orderId}")
	List<Items> getItemsByOrderId(@Param("orderId") int orderId);

	@Delete("delete from items where order_id = #{orderId}")
	void itemsDelete(int orderId);

	//新增订单项。
	@Insert("insert into items (price,amount,order_id,good_id) values (#{price},#{amount},#{orderId},#{goodId})")
	@SelectKey(keyProperty="id",statement="SELECT LAST_INSERT_ID()", before=false, resultType=Integer.class)  
	void insert(Items item);

	//查询某个订单的所有订单项。
    @Select("select * from items where order_id=#{orderId}")
	public List<Items> selectList(int orderId);
}
